package LCR_code;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author blh
 * @date 2024年08月05日 19:22
 */
public class LCR_164_85 {
    public String crackPassword(int[] password) {
        int len = password.length;
        List<String> list = Arrays.stream(password).mapToObj(String::valueOf).collect(Collectors.toList());
        list.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                String temp1 = o1 + o2;
                String temp2 = o2 + o1;
                BigInteger big1 = new BigInteger(temp1);
                BigInteger big2 = new BigInteger(temp2);
                return big1.compareTo(big2);
            }
        });
        return String.join("", list);
    }
}
